Containers are isolated from one another and bundle their own software, libraries and configuration files; they can communicate with each other through well-defined channels. Because all of the containers share the services of a single operating system kernel, they use fewer resources than virtual machines.
Kubernetes is an open-source container orchestration system for automating software deployment, scaling, and management.
➜ More things to do, less administrators
Atomicity is a property that ensures that a database follows the all or nothing rule. In other words, the database considers all transaction operations as one whole unit or atom.Source: Techopedia
Consistency is a property ensuring that only valid data following all rules and constraints is written in the database. When a transaction results in invalid data, the database reverts to its previous state, which abides by all customary rules and constraints.Source: Techopedia
Isolation is a property that guarantees the individuality of each transaction, and prevents them from being affected from other transactions. It ensures that transactions are securely and independently processed at the same time without interferenceSource: Techopedia
Durability is a property that enforces completed transactions, guaranteeing that once each one of them has been committed, it will remain in the system even in case of subsequent failures.Source: Techopedia
The way containers are designed, and particularly the way Docker is designed, the assumption is that the container is stateless.Mark Davis, ClusterHQ, 17 Jun 2015
Some tried early...
... And failed
It shouldn't be a reason not to try again!
Kubernetes 1.14 and persistent volumes
70% of 500 executives and technology leaders are running stateful workloads in production with databases topping the list.dok report 2021
# Example of PostgreSQL cluster
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: cluster-example
spec:
instances: 3
primaryUpdateStrategy: unsupervised
storage:
size: 1Gi
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
# [...]
spec:
# [...]
imageName: ghcr.io/cloudnative-pg/postgresql:13.6
#[...]
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
# [...]
spec:
backup:
barmanObjectStore:
destinationPath: "[destination path here]"
s3Credentials:
accessKeyId:
name: aws-creds
key: ACCESS_KEY_ID
secretAccessKey:
name: aws-creds
key: ACCESS_SECRET_KEY
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
# [...]
spec:
postgresql:
parameters:
shared_buffers: "1GB"
auto_explain.log_min_duration: "10s"
pg_hba:
- host laetitia laetitia all scram-sha-256
# [...]
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
# [...]
resources:
requests:
memory: "32Mi"
cpu: "50m"
limits:
memory: "128Mi"
cpu: "100m"
# [...]
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: cluster-example
spec:
selector:
matchLabels:
postgresql: cluster-example
podMetricsEndpoints:
- port: metrics
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: cluster-example
# [...]
spec:
# [...]
monitoring:
customQueriesConfigMap:
- name: example-monitoring
key: custom-queries
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: cluster-monolith
spec:
bootstrap:
initdb:
import:
type: monolith
databases:
- banking
roles:
- bank_user
source:
externalCluster: cluster-pg96
...
...
externalClusters:
- name: cluster-pg96
connectionParameters:
# Use the correct IP or host name for the source database
host: pg96.local
user: postgres
dbname: postgres
sslmode: require
password:
name: cluster-pg96-superuser
key: password
imageName
resources
primaryUpdateStrategy:unsupervised
primaryUpdateStrategy:supervised
kubectl logs
It depends...
Your Postgres database still needs